import cv2 as cv
import numpy as np

img = cv.imread('../data/jWithBlackNoiseLeft.png')
kernel = np.ones((5,5),np.uint8)

blackhat = cv.morphologyEx(img,cv.MORPH_BLACKHAT,kernel)

closing = cv.morphologyEx(blackhat,cv.MORPH_CLOSE,kernel)
cmi = closing - img

res = np.hstack((img,closing,blackhat,cmi))

cv.imshow('res',res)

cv.waitKey(0)
cv.destroyAllWindows()